﻿using System;

namespace ExFlash.Tags
{
    public class DefineBitsTag : Tag, IHasCharacterId
    {
        public ushort CharacterId
        {
            get;
            protected set;
        }

        public Byte[] ImageData
        {
            get;
            protected set;
        }

        protected DefineBitsTag(TagCodes code,int len, int offset)
            : base(code, len,offset)
        {

        }

        public DefineBitsTag(int len, int offset)
            : this(TagCodes.DefineBits,len,offset)
        {

        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            CharacterId = reader.ReadUInt16();

            int arrLength = TagLength - 2;

            ImageData = new Byte[arrLength];
            reader.Read(ImageData, 0, arrLength);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #region IHasCharacterID Members

        public ushort Id
        {
            get { return CharacterId; }
        }

        #endregion
    }
}
